package com.zj.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zj.model.UserRedPacket;
import com.zj.web.bean.UserRedPacketDTO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserRedPacketMapper extends BaseMapper<UserRedPacket> {
    //根据用户id查询领取过的红包活动信息
    @Select("select urp.activityId,amount,receivedAt,title\n" +
            "from user_red_packet urp\n" +
            "left join red_packet_activity ra on urp.activityId=ra.activityId\n" +
            "where urp.userId=#{userId};")
    @Results({
            @Result(column = "activityId", property = "activityId"),
            @Result(column = "amount", property = "amount"),
            @Result(column = "receivedAt", property = "receivedAt"),
            @Result(column = "title", property = "title"),
    })
    List<UserRedPacketDTO> findByUserId(@Param("userId") Long userId);
}
